package com.example.demo.service.My;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.myModel.entity.Email;
import com.example.demo.myModel.entity.MyUser;
import com.example.demo.myModel.entity.Teacher;
import com.example.demo.myModel.otd.user.UserLoginRequest;
import com.example.demo.myModel.otd.user.UserQueryRequest;
import com.example.demo.myModel.vo.AdminLoginVo;
import com.example.demo.myModel.vo.UserLoginVo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;


/**
 * 用户服务
 */
public interface MyUserService extends IService<MyUser> {

    /**
     * 用户注册
     *
     * @return 新用户 id
     */
    long userRegister(MyUser user, HttpSession session);


    /**
     * 学生登录
     *
     * @param userLoginRequest 登录信息
     * @param request          网络请求信息
     * @return 用户信息
     */
    UserLoginVo userLogin(UserLoginRequest userLoginRequest, HttpServletRequest request);


    /**
     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    MyUser getLoginUser(HttpServletRequest request);

    /**
     * 获取当前登录用户（允许未登录）
     *
     * @param request
     * @return
     */
    MyUser getLoginUserPermitNull(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param myUser
     * @return
     */
    boolean isAdmin(MyUser myUser);

    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    UserLoginVo getLoginUserVO(MyUser myUser);


    /**
     * 获取脱敏的已登录管理员信息
     */
    AdminLoginVo getLoginAdminVO(Teacher teacher);

    /**
     * 获取脱敏的用户信息
     *
     * @param myUser
     * @return
     */
    UserLoginVo getUserVO(MyUser myUser);

    /**
     * 获取脱敏的用户信息
     *
     * @param myUserList
     * @return
     */
    List<UserLoginVo> getUserVO(List<MyUser> myUserList);

    /**
     * 获取查询条件
     *
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<MyUser> getQueryWrapper(UserQueryRequest userQueryRequest);


    /**
     * 发送邮箱验证码
     *
     * @param email
     * @return
     */
    boolean sentEmailCode(Email email, HttpSession session);


    /**
     * 生成n位随机数
     *
     * @param n
     * @return
     */
    String randomCode(int n);

    /**
     * 验证注册码
     *
     * @param info
     * @param session
     * @return
     */
    boolean registered(MyUser info, HttpSession session);




}
